package tmproject.hlhj.fhp.cartrans.modules

import android.content.Context
import com.example.mymvp.BaseModule
import com.lzy.okgo.model.Response
import tmproject.hlhj.fhp.cartrans.http.Apis
import tmproject.hlhj.fhp.cartrans.http.BaseAciton
import tmproject.hlhj.fhp.cartrans.http.BaseObserver
import tmproject.hlhj.fhp.cartrans.http.LoadingAction
import tmproject.hlhj.fhp.cartrans.javaBean.BaseBean
import tmproject.hlhj.fhp.cartrans.javaBean.CarInfoBean
import tmproject.hlhj.fhp.cartrans.utils.SpHelper

class CarModule:BaseModule {
    var listener:CarInfoResp?=null
    fun getCarinfo(c:Context,id:Int){
        Apis.getCarInfo(SpHelper.getToken(c)!!,id)
                ?.let {
                    it
                            .subscribe(object :BaseObserver<Response<CarInfoBean>>(c){
                                override fun failed(e: Throwable?) {
                                }

                                override fun httpSuccess(t: Response<CarInfoBean>) {
                                    listener?.setCarInfo(t.body())
                                }

                                override fun httpErroCode(baseBean: BaseBean) {
                                }
                            })
                }
    }

    interface CarInfoResp{
        fun setCarInfo(carInfoBean: CarInfoBean)
    }
}